/*
 * Rotator.java
 *
 * Created on May 11, 2006, 3:24 PM
 *
 * @author  Francois Daniels
 */

import org.jfree.chart.plot.PiePlot3D;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.Timer;

/**
 * This class is responsible for rotating the graph image.
 *
 * @author  Francois Daniels
 */
class Rotator extends Timer implements ActionListener {
    
    /** The plot which we could like to rotate. */
    private PiePlot3D plot;
    
    /** The starting angle. */
    private int angle = 270;
    
    /**
     * Constructor.
     *
     * @param plot  The plot we would like to rotate.
     */
    Rotator (final PiePlot3D plot) {
        super (100, null);
        this.plot = plot;
        addActionListener (this);
    }
    
    /**
     * Modifies the starting angle.
     *
     * @param event  The action event.
     */
    public void actionPerformed (final ActionEvent event) {
        this.plot.setStartAngle (this.angle);
        this.angle = this.angle + 1;
        if (this.angle == 360) {
            this.angle = 0;
        }
    }
    
}